package org.sundayli;

import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelHandler;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import org.sundayli.config.ConfigManager;

public class Main {
  private static final ConfigManager configManager = ConfigManager.init();
  public static void main(String[] args) {
    ChannelHandler channelHandler = new RedisCommandDecoder(configManager);
    EventLoopGroup workerGroup = new NioEventLoopGroup();
    // tcp server
    ServerBootstrap serverBootstrap = new ServerBootstrap();
    serverBootstrap
      .group(workerGroup)
      .channel(NioServerSocketChannel.class)
      .childHandler(channelHandler)
      .bind(configManager.getPort());
  }
}